home *** CD-ROM | disk | FTP | other *** search
/ Internet Surfer 2.0 / Internet Surfer 2.0 (Wayzata Technology) (1996).iso / pc / faq / faqs / motf_faq / part4 < prev    next >
Encoding:
Text File  |  1992-12-26  |  38.2 KB  |  959 lines

  1. Xref: bloom-picayune.mit.edu comp.windows.x.motif:13660 news.answers:4511
  2. Newsgroups: comp.windows.x.motif,news.answers
  3. Path: bloom-picayune.mit.edu!enterpoop.mit.edu!news.media.mit.edu!micro-heart-of-gold.mit.edu!wupost!uunet!munnari.oz.au!manuel.anu.edu.au!csc.canberra.edu.au!news
  4. From: jan@ise.canberra.edu.au (Jan Newmarch)
  5. Subject: Motif FAQ (Part 4 of 5)
  6. Message-ID: <1992Dec10.001632.10561@csc.canberra.edu.au>
  7. Followup-To: comp.windows.x.motif
  8. Keywords: FAQ question answer
  9. Sender: news@csc.canberra.edu.au
  10. Reply-To: jan@ise.canberra.edu.au (Jan Newmarch)
  11. Organization: University of Canberra
  12. Date: Thu, 10 Dec 92 00:16:32 GMT
  13. Approved: news-answers-request@MIT.Edu
  14. Expires: +1 months
  15. Lines: 942
  16.  
  17. Archive-name: motif-faq/part4
  18. Last-modified: Thu December 12 1992
  19. Version: 2.12
  20.  
  21.  
  22.  
  23.  
  24. -----------------------------------------------------------------------------
  25. Subject: 88) TOPIC: XMSTRING
  26.  
  27. -----------------------------------------------------------------------------
  28. Subject: 89) How can I get the Ascii text out of an XmString?
  29.  
  30. Answer: To get the first line of text from a string created left-to-right
  31.  
  32.  
  33.         char *str;
  34.         XmString xmstr;
  35.  
  36.         /* stuff to create xmstr */
  37.         ...
  38.  
  39.         /* set str to point to the text */
  40.         XmStringGetLtoR(xmstr, XmSTRING_DEFAULT_CHARSET, &str);
  41.         /* use the string */
  42.         ...
  43.  
  44.         /* and reclaim space */
  45.         XtFree(str);
  46.  
  47.  
  48. -----------------------------------------------------------------------------
  49. Subject: 90) When can XmStrings used as resources be freed?
  50.  
  51. Answer: The policy OSF have been trying to enforce is that if you set an
  52. XmString or XmStringTable resource, the application is responsible for freeing
  53. the XmStrings used because the widget makes a copy.  If you get an XmString
  54. resource, then the application must free the value gotten.  If you get an
  55. XmStringTable, then the application should NOT free the value gotten.  If the
  56. application wants to manipulate it, it should make a copy first. This policy
  57. appears to be implemented progressively, so may be less true for Motif 1.0
  58. than 1.1.
  59.  
  60. -----------------------------------------------------------------------------
  61. Subject: 91) Why doesn't XmStringGetNextSegment() work properly?
  62.  
  63. Answer: The documentation in Motif 1.0 is in error. Instead of
  64.  
  65.         XmStringGetnextSegment(context, ...)
  66.         XmStringContext * context;
  67.  
  68. it should be
  69.  
  70.         XmStringGetnextSegment(context, ...)
  71.         XmStringContext context;
  72.  
  73. i.e. with no indirection.
  74.  
  75. -----------------------------------------------------------------------------
  76. Subject: 92) TOPIC: DIALOGS
  77.  
  78. -----------------------------------------------------------------------------
  79. Subject: 93) How do I stop my dialog disappearing when I press the help
  80. button?
  81.  
  82. Answer: Bulletin board has the resource autoUnmanage which defaults to True.
  83. This unmanages the widget when any button child is activated - including the
  84. help button.  Set this to False to stop it disappearing. Note that you then
  85. have to unmanage the bulletin board yourself when any other button is
  86. activated.
  87.  
  88. -----------------------------------------------------------------------------
  89. Subject: 94) How do I make my own dialog?  I want a dialog with my own set of
  90. buttons that stretch and shrink like the ones in e.g. PromptDialog and its own
  91. contents.
  92.  
  93. Answer: Start off with say a PromptDialog. Unmanage the buttons you don't want
  94. or manage the Apply button if you want another. Unmanage the other bits of the
  95. selection box you don't want. You can add another WorkArea child to the
  96. selection box for any extra stuff you want.
  97.  
  98.     /* Copyright 1990, Kee Hinckley and Brian Holt Hawthorne */
  99.     /* Permission granted for any use, provided this copyright */
  100.     /* notice is maintained. */
  101.  
  102.     /* Create a dialog box */
  103.     argcount = setArgs(&args, XmNautoUnmanage, False, NULL);
  104.     SomeDialog = XmCreatePromptDialog(mainShell, "someDialog", args, argcount);
  105.  
  106.     /* Now get rid of the things we don't want */
  107.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_SELECTION_LABEL);
  108.     XtUnmanageChild(child);
  109.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_TEXT);
  110.     XtUnmanageChild(child);
  111.  
  112.     /* set the callbacks, and make sure the buttons we want are there */
  113.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_OK_BUTTON);
  114.     XtAddCallback(child, XmNactivateCallback, callSomeFunc, someArg);
  115.     XtAddCallback(child, XmNactivateCallback, unManage, SomeDialog);
  116.     XtManageChild(child);
  117.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_APPLY_BUTTON);
  118.     XtAddCallback(child, XmNactivateCallback, callSomeFunc, someOtherArg);
  119.     XtManageChild(child);
  120.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_CANCEL_BUTTON);
  121.     XtAddCallback(child, XmNactivateCallback, dialogUnmanage, SomeDialog);
  122.     XtManageChild(child);
  123.  
  124.     /* Add a new work area. This can be any manager. */
  125.     child = XmCreateForm(SomeDialog, "someForm", NULL, 0);
  126.     XtManageChild(child);
  127.  
  128.     /* and fill it up... */
  129.     something = doYourStuff(child);
  130.  
  131.  
  132.  
  133. -----------------------------------------------------------------------------
  134. Subject: 95) How come the title bars for my dialogs now have "_popup" or "<-
  135. popup" concatenated onto the widget name?
  136.  
  137.  
  138. Answer: Motif 1.0.3 (?) "fixed" things such that title bars without an
  139. explicit dialogTitle setting use the widget name with "_popup" or whatever
  140. added on.  Set the dialogTitle resource explicitly if you don't want this new
  141. default naming scheme.
  142.  
  143. -----------------------------------------------------------------------------
  144. Subject: 96) How can I force a dialog window to display?  I manage a "working"
  145. dialog, and do some computing, but the dialog window appears blank until the
  146. work has finished.  How can I force it to be displayed?
  147.  
  148. Answer: Use this.  (David Brooks, Systems Engineering, Open Software
  149. Foundation)
  150.  
  151. /*
  152.  * This procedure will ensure that, if a dialog window is being mapped,
  153.  * its contents become visible before returning.  It is intended to be
  154.  * used just before a bout of computing that doesn't service the display.
  155.  * You should still call XmUpdateDisplay() at intervals during this
  156.  * computing if possible.
  157.  *
  158.  * The monitoring of window states is necessary because attempts to map
  159.  * the dialog are redirected to the window manager (if there is one) and
  160.  * this introduces a significant delay before the window is actually mapped
  161.  * and exposed.  This code works under mwm, twm, uwm, and no-wm.  It
  162.  * doesn't work (but doesn't hang) with olwm if the mainwindow is iconified.
  163.  *
  164.  * The argument to ForceDialog is any widget in the dialog (often it
  165.  * will be the BulletinBoard child of a DialogShell).
  166.  */
  167.  
  168. ForceDialog(w)
  169.      Widget w;
  170. {
  171.   Widget diashell, topshell;
  172.   Window diawindow, topwindow;
  173.   Display *dpy;
  174.   XWindowAttributes xwa;
  175.   XEvent event;
  176.   XtAppContext cxt;
  177.  
  178. /* Locate the shell we are interested in.  In a particular instance, you
  179.  * may know these shells already.
  180.  */
  181.  
  182.   for (diashell = w;
  183.        !XtIsShell(diashell);
  184.        diashell = XtParent(diashell))
  185.     ;
  186.  
  187. /* Locate its primary window's shell (which may be the same) */
  188.  
  189.   for (topshell = diashell;
  190.        !XtIsTopLevelShell(topshell);
  191.        topshell = XtParent(topshell))
  192.     ;
  193.  
  194.   if (XtIsRealized(diashell) && XtIsRealized(topshell)) {
  195.     dpy = XtDisplay(topshell);
  196.     diawindow = XtWindow(diashell);
  197.     topwindow = XtWindow(topshell);
  198.     cxt = XtWidgetToApplicationContext(diashell);
  199.  
  200. /* Wait for the dialog to be mapped.  It's guaranteed to become so unless... */
  201.  
  202.     while (XGetWindowAttributes(dpy, diawindow, &xwa),
  203.            xwa.map_state != IsViewable) {
  204.  
  205. /* ...if the primary is (or becomes) unviewable or unmapped, it's
  206.    probably iconified, and nothing will happen. */
  207.  
  208.       if (XGetWindowAttributes(dpy, topwindow, &xwa),
  209.           xwa.map_state != IsViewable)
  210.         break;
  211.  
  212. /* At this stage, we are guaranteed there will be an event of some kind.
  213.    Beware; we are presumably in a callback, so this can recurse. */
  214.  
  215.       XtAppNextEvent(cxt, &event);
  216.       XtDispatchEvent(&event);
  217.     }
  218.   }
  219.  
  220. /* The next XSync() will get an expose event if the dialog was unmapped. */
  221.  
  222.   XmUpdateDisplay(topshell);
  223. }
  224.  
  225.  
  226. -----------------------------------------------------------------------------
  227. Subject: 97) How can I control placement of a popup widget?  Each time a popup
  228. is created, it is placed in or over the middle of its parent.  How can I make
  229. it obey the XmNx and XmNy values?
  230.  
  231. Answer: Set the resource XmNdefaultPosition for the popup to False.  Set the
  232. position of the popup by the resource values of XmNx and XmNy.  Do not use
  233. XtMoveWidget, as this is for widget writers only.  Here's a demo program from
  234. Dan Heller:
  235.  
  236. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  237.  * This program is freely distributable without licensing fees and
  238.  * is provided without guarantee or warranty expressed or implied.
  239.  * This program is -not- in the public domain.  This program is
  240.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  241.  */
  242.  
  243. /* map_dlg.c -- Use the XmNmapCallback to automatically position
  244.  * a dialog on the screen.  Each time the dialog is displayed, it
  245.  * is mapped down and to the right by 200 pixels in each direction.
  246.  */
  247. #include <Xm/MessageB.h>
  248. #include <Xm/PushB.h>
  249.  
  250. /* main() --create a pushbutton whose callback pops up a dialog box */
  251. main(argc, argv)
  252. char *argv[];
  253. {
  254.     Widget toplevel, button;
  255.     XtAppContext app;
  256.     void pushed();
  257.  
  258.     toplevel = XtVaAppInitialize(&app, "Demos",
  259.         NULL, 0, &argc, argv, NULL, NULL);
  260.  
  261.     button = XtCreateManagedWidget("button", xmPushButtonWidgetClass,
  262.         toplevel, NULL, 0);
  263.     XtAddCallback(button, XmNactivateCallback, pushed, "Hello World");
  264.  
  265.     XtRealizeWidget(toplevel);
  266.     XtAppMainLoop(app);
  267. }
  268.  
  269. /* callback function for XmNmapCallback.  Position dialog in 200 pixel
  270.  * "steps".  When the edge of the screen is hit, start over.
  271.  */
  272. static void
  273. map_dialog(dialog, client_data, cbs)
  274. Widget dialog;
  275. XtPointer client_data;
  276. XmAnyCallbackStruct *cbs;
  277. {
  278.     static Position x, y;
  279.     Dimension w, h;
  280.  
  281.     XtVaGetValues(dialog, XmNwidth, &w, XmNheight, &h, NULL);
  282.     if ((x + w) >= WidthOfScreen(XtScreen(dialog)))
  283.         x = 0;
  284.     if ((y + h) >= HeightOfScreen(XtScreen(dialog)))
  285.         y = 0;
  286.     XtVaSetValues(dialog, XmNx, x, XmNy, y, NULL);
  287.     x += 200, y += 200;
  288. }
  289.  
  290. /* pushed() --the callback routine for the main app's pushbutton.
  291.  * Create and popup a dialog box that has callback functions for
  292.  * the Ok, Cancel and Help buttons.
  293.  */
  294. void
  295. pushed(w, message)
  296. Widget w;
  297. char *message; /* The client_data parameter passed by XtAddCallback */
  298. {
  299.     Widget dialog;
  300.     Arg arg[3];
  301.     XmString t = XmStringCreateSimple(message);
  302.     extern void response();
  303.  
  304.     XtSetArg(arg[0], XmNautoUnmanage, False);
  305.     XtSetArg(arg[1], XmNmessageString, t);
  306.     XtSetArg(arg[2], XmNdefaultPosition, False);
  307.     dialog = XmCreateMessageDialog(w, "notice", arg, 3);
  308.     XmStringFree(t);
  309.  
  310.     XtAddCallback(dialog, XmNmapCallback, map_dialog, NULL);
  311.  
  312.     XtManageChild(dialog);
  313.     XtPopup(XtParent(dialog), XtGrabNone);
  314. }
  315.  
  316.  
  317. -----------------------------------------------------------------------------
  318. Subject: 98) TOPIC: LANGUAGE BINDINGS
  319.  
  320. -----------------------------------------------------------------------------
  321. Subject: 99)*  Is there a C++ binding for Motif?
  322. [Last modified: November 92]
  323.  
  324.  
  325. Answer: WWL is a library which defines C++ classes around X Toolkit Widgets.
  326. It is intended to simplify the task of C++ code writers when using the Toolkit
  327. by providing them with C++ objects, methods, type checking and several utility
  328. functions and classes.
  329.  
  330. WWL has been tested under SunOs4.0.3 on sun3 and sun4, HPUX version 6.5 and
  331. 7.0 and Ultrix 4.0 on DECstation 3100 and 5000. It is expected to work on most
  332. other UNIX systems without too many problems.
  333.  
  334. WWL is distributed as a tar file with all the source, documentation and
  335. example. The file is available using anonymous ftp from
  336.  
  337.         export.lcs.mit.edu (18.30.0.238   contrib/WWL-1.0.tar.Z
  338.         lri.lri.fr (129.175.15.1)      pub/WWL-1.0.tar.Z
  339.  
  340.  
  341. Answer: Rogue Wave Software has a C++ binding for Motif called View.h++.
  342.  
  343. "View.h++ is a complete C++ interface to OSF/Motif.  It doesn't just
  344. encapsulate it, but also includes a set of classes that provide a level of
  345. abstraction above Motif, thus simplifying menu and dialog creation, XmStrings,
  346. XmFontLists, etc.  View.h++ supports a Model- View-Controller architecture,
  347. allowing for an even more object-oriented interface design.  Includes a copy
  348. of Rogue Wave's Tools.h++ (foundation class library)"
  349.  
  350. An object license is $795 "per seat" and a source code license is available
  351. for $2,995 "per seat."  Rogue Wave also offers full support for View.h++.
  352.  
  353. It is currently available for Sun Sparc, IBM RS/6000, HP 9000/700 series, SCO,
  354. Intel SVR4 ESIX.  Please call for Silicon Graphics and DEC Ultrix status.
  355.  
  356. For additional information, please contact:
  357.  
  358. Matt Steinauer
  359. Rogue Wave Software, Inc.
  360. P.O. Box 2328
  361. Corvallis, OR 97339
  362. Phone: (503)754-3010
  363. Fax:   (503)757-6650
  364.  
  365. email:   matts@roguewave.com
  366.  
  367.  
  368. Answer: From Andreas.Baecker@gmd.de: The GINA++ application framework contains
  369. an encapsulation of the OSF/Motif widg et classes and the Xt functionality
  370. into C++ classes. Its functionality is comparab le to that of the ULowell
  371. binding and the WWL. Additionally, it provides an easy-to -use framework for
  372. modeling new composite and primitive widget classes, plus an application
  373. framework similar to ET++ or MacApp build on top of it. The binding may be
  374. used independently from the framework classes. GINA++ is available through
  375. anonymous ftp from ftp.gmd.de [129.26.8.90] in the directory /gmd/ginaplus.
  376. Documentation about the Motif binding has been published in the X Resource
  377. Journ al, Number 2, 1992, Pages 106-130. The binding compiles with AT&T C++
  378. 2.1 and GNU G+ + 2.1 and has been tested on SunOS 4.1.[12], X11R4 and Motif
  379. 1.1.3.
  380.  
  381. Answer: Motif++ is a library that defines C++ class "wrappers" for the widgets
  382. defined in the OSF/Motif-1.1 widget library. Motif++ is also an application
  383. toolkit that provides other tools in conjunction with the widget wrapper
  384. classes.  It has support for the Xbae widget set, plus other widgets.  It has
  385. Imake support, and lots of test files.
  386.  
  387. Motif++ is very similar to other public domain widget libraries such as The
  388. Widget Wrapper Library (WWL) and the C++ Binding for OSF/Motif developed at
  389. the Univeristy of Lowell. The two latter libraries are the result of much
  390. larger efforts.
  391.  
  392. Availability:
  393.  
  394. Anonymous ftp at decuac.dec.com (192.5.214.1), directory /pub/X11,
  395. file motif++.21.jul.92.tar.Z (855293 bytes).
  396.  
  397. For more information, contact Ronald van Loon (rvloon@cv.ruu.nl)
  398.  
  399.  
  400. Answer: The Solbourne OI toolkit (not Motif) also has a C++ binding.
  401.  
  402. Answer: Doug Young has written a book "Object Oriented Programming with C++
  403. and Motif", Prentice-Hall ISBN 0-13-630252-1 about using C++ without requiring
  404. one of these toolkits.
  405.  
  406. -----------------------------------------------------------------------------
  407. Subject: 100)+ How can I have a C++ member function in a callback?
  408.  
  409. [Last modified: November 92]
  410.  
  411. Answer: Motif++ has a nice tutorial summarising mechanisms. Doug Young's book
  412. deals extensively with one of these. The problem is that you don't get the
  413. object when you just use the function as a callback.  You need to pass the
  414. object as a pointer through as the client_data.  (use "this" as the
  415. client_data.) Then you can retrieve the object's address, and dereference from
  416. there. For example (Leo O'Donnell, Email: leo@avs.com),
  417.  
  418.     class MyButton {
  419.       public:
  420.                 MyButton (Widget parent, const char *name) {
  421.                     _button = XtVaCreateManagedWidget (
  422.                         name, xmPushButtonWidgetClass, parent, NULL, 0);
  423.                     XtAddCallback (
  424.                         _button,
  425.                         XmNactivateCallback,
  426.                         &MyButton::activateCB,
  427.                         (XtPointer) this);
  428.                 }
  429.                 ~MyButton () { XtDestoryWidget (_button); }
  430.       private:
  431.         Widget  _button;
  432.         static  void activateCB (Widget, XtPointer, XtPointer);
  433.     };
  434.  
  435.     void MyButton::activateCB (Widget, XtPointer thisBtn, XtPointer)
  436.     {
  437.         MyButton *btn = (MyButton *) thisBtn;
  438.  
  439.         // OK you've got the button instance now. Do some stuff with it!
  440.     }
  441.  
  442.  
  443.  
  444. -----------------------------------------------------------------------------
  445. Subject: 101)* Is there a Common Lisp binding for Motif?
  446.  
  447. [Last modified: November 92]
  448.  
  449. Answer: Try CLM. This includes a toolkit demon (in C) that takes a widget
  450. description (with callbacks), and forks a new process for each Motif
  451. application (which can be just a single menu, or whatever).  Lisp can then
  452. continue running, with a separate lightweight lisp process handling the
  453. connection & callbacks.  In North America & net environs, CLM-2.0beta is
  454. available from export.lcs.mit.edu.
  455.  
  456. There is also CLIM, the Common Lisp Interface Manager. It provides access to
  457. motif and other toolkits and window systems.  Here is some blurb: "Version 2.0
  458. of the Common Lisp Interface Manager (CLIM) provides access to Motif. CLIM is
  459. the emerging standard for GUI development in Common Lisp.  It offers a set of
  460. high-level facilities that enable rapid construction of user interfaces.
  461. Applications written using CLIM are portable across a variety of window
  462. systems and toolkits.  For example, on the X window System, both Motif
  463. (OSF/Motif) and Openlook (OLIT) are supported.  CLIM accesses the toolkit
  464. directly rather than emulating the look and feel."
  465.  
  466. CLIM is available from a variety of Common Lisp vendors including Symbolics
  467. and Franz Inc. (info@franz.com).
  468.  
  469.  
  470. -----------------------------------------------------------------------------
  471. Subject: 102)  Is there an Ada binding for Motif?
  472.  
  473. Answer:
  474.  
  475. From Todd W. Lainhart: Take a look at THINGS, a VAPI with Ada bindings that
  476. was written by the US Air Force (SAC).  It's in the public domain, and
  477. available from export or gatekeeper.dec.com.  It implements Motif or OL look-
  478. and-feel. [I had a look and it seemed to be missing documentation - Jan]
  479.  
  480. From David Lewis: A company called Rational appears to be making an Xm
  481. implementation.  Also GHG in Texas has most other Xlib and Xt bindings for
  482. Ada.
  483.  
  484. From comp.windows.x FAQ: Ada bindings to Motif, explicitly, will eventually be
  485. made available by the Jet Propulsion Laboratories, probably through the normal
  486. electronic means.  Advance information can be obtained from
  487. dsouleles@dsfvax.jpl.nasa.gov, who may respond as time permits.  Another set
  488. of bindings for Motif is being done by the University of Lowell; information
  489. is available from osfri@osf.org.[11/90]
  490.  
  491. TeleSoft has bindings for Motif, Xt and Xlib.  They are called TeleWindows.
  492. Contact their customer support department for more information.
  493.  
  494.      TeleSoft
  495.      5959 Cornerstone Court West
  496.      San Diego, CA 92121-9891
  497.      +1 619-457-2700
  498.      +1 619-452-1334 Fax
  499.  
  500.      Email: adasales@telesoft.com (Sales)
  501.             adasupport@telesoft.com (Customer Support)
  502.  
  503.  
  504. TAE Plus will generate either Ada or C. Contact
  505.  
  506.         Goddard Space Flight Center
  507.         TAE Suppport Office
  508.         Code 522
  509.         Attn: Arleen Yeager
  510.         Greenbelt, MD  20771
  511.         301-286-6034
  512.         FTS 888-6034
  513.  
  514.         e-mail:  taeso@postman.gsfc.nasa.gov
  515.  
  516.         TELEMAIL from a NASA facility:      TELEMAIL outside of NASA:
  517.         [TAESO/GSFCMAIL]GSFC                [TAESO/GSFCMAIL]GSFC/USA
  518.         SPAN is 6162::TAESO
  519.  
  520. SA-Motif is a complete binding to X Window and Motif for the Ada; it is based
  521. in part upon the SAIC/Unisys bindings. SA-Motif is available on the Sun3,
  522. Sun4,  SCO, HPUX, and SGI IRIX. Info: Systems Engineering Research
  523. Corporation, 2348 Leghorn Street, #202/Mountain View, CA 94043/1-800-Ada-SERC
  524. (well!serc@apple.com).
  525.  
  526.  
  527.  
  528. -----------------------------------------------------------------------------
  529. Subject: 103) TOPIC: SPECIFIC PLATFORMS
  530.  
  531. -----------------------------------------------------------------------------
  532. Subject: 104) Is it easy to build Motif for a Sun?
  533.  
  534. Answer: No pattern has emerged to problems about compiling Motif on the Sun
  535. (although people seem to have a lot of different minor problems), and many
  536. reports are that it is straightforward. Read the Motif install instructions
  537. (which often have specific reference to Sun installation), light the blue
  538. touch paper and just standback. [My experience was that I had to add
  539. -D_NO_PROTO for 1.1 on a Sparc OS 4.1, and that was all.  Others have added
  540. STRINGS_ALIGNED and NO_REGEXP].
  541.  
  542.  
  543. -----------------------------------------------------------------------------
  544. Subject: 105) What compile errors/warnings might I get in both Sun 3 and Sun
  545. 4?
  546.  
  547. Answer:
  548.  
  549.  
  550. make: Warning: Too many rules defined for target
  551. make: Warning: Too many rules defined for target
  552. "callbacks.c", line 1530: warning: illegal combination of pointer
  553. and integer, op =
  554. "callbacks.c", line 1531: warning: illegal combination of pointer
  555. and integer, op =
  556. "callbacks.c", line 1532: warning: illegal combination of pointer
  557. and integer, op =
  558. "utils.c", line 73: warning: illegal combination of pointer and integer, op =
  559. "utils.c", line 74: warning: illegal combination of pointer and integer, op =
  560. "utils.c", line 122: warning: illegal combination of pointer and integer, op =
  561. "utils.c", line 123: warning: illegal combination of pointer and integer, op =
  562. "utils.c", line 191: warning: illegal combination of pointer and integer, op =
  563. "utils.c", line 194: warning: illegal combination of pointer and integer, op =
  564. "utils.c", line 195: warning: illegal combination of pointer and integer, op =
  565. "utils.c", line 196: warning: illegal combination of pointer and integer, op =
  566. "utils.c", line 316: warning: illegal combination of pointer and integer, op =
  567. "utils.c", line 334: warning: illegal combination of pointer and integer, op =
  568. "utils.c", line 338: warning: illegal combination of pointer and integer, op =
  569. "utils.c", line 341: warning: illegal combination of pointer and integer, op =
  570. "xmdialogs.c", line 838: warning: illegal combination of pointer
  571. and integer, op =
  572. "xmeditor.c", line 1152: warning: illegal combination of pointer
  573. and integer, op =
  574.  
  575. These warning messages can be ignored. OSF is aware of these warnings.
  576.  
  577.  
  578. -----------------------------------------------------------------------------
  579. Subject: 106) On a Sun 3, what are the mwm startup error messages about?  I
  580. get
  581.  
  582. mwm: Invalid accelerator specification on line 7 of
  583.      specification string
  584. mwm: Invalid accelerator specification on line 31 of
  585.       configuration file
  586.  
  587.  
  588. Answer: This is because some Sun keyboards do not have an F10 key and some sun
  589. workstations which have an F10 key do not have X-servers which recognize it.
  590. The F10 key is used by mwm.  If the machine does have an F10 key, the user
  591. should use xmodmap to tell the server it exists.  Otherwise, change the
  592. definition of the DefaultWindowMenu in /usr/lib/X11/system.mwmrc (after
  593. installation) or in /lib/clients/mwm/system.mwmrc (before installation).
  594. Change the accelerator of "Maximize" (it is "Alt<Key>F10)" to something else.
  595. Also, you should change the definition of DEFAULTSYSTEMMENU in the file
  596. /clients/mwm/WmResource.c in a similar fashion.  There is as yet no standard
  597. redefinition for F10.
  598.  
  599.  
  600.  
  601. -----------------------------------------------------------------------------
  602. Subject: 107) Are there problems making shared libraries on a Sun?
  603.  
  604. Answer: If you use the -pic option you may run out of offset table space.  use
  605. the -PIC option instead.
  606.  
  607. You may get the message "ld.so: Undefined symbol: __XtInherit" when executing
  608. UIL. There is a problem in shared library build when you compare a function
  609. variable to a routine name, but don't call the routine.  Either, you can build
  610. the Xt library nonshared, or you can put a reference to XtToolkitInitialize in
  611. the UIL main program (or even include a module that references it).  The
  612. routine doesn't even have to be called; it just has to be there.
  613.  
  614.  
  615. -----------------------------------------------------------------------------
  616. Subject: 108)  The OpenWindows server hangs when I popup a menu with Button 3.
  617. [Last modified: August 92]
  618.  
  619. Answer: This is an OpenWindows problem, but if you have Motif source you can
  620. fix your own applications. From Steve Sistare of Thinking Machines Corp.:
  621. "Change the 2 calls to XtGrabButton in RowColumn.c such that ButtonReleaseMask
  622. | ButtonPressMask is passed for the event mask.  Currently, only
  623. ButtonReleaseMask is passed.  Also, change the owner_event argument to FALSE.
  624. " This has not been fixed in Motif as at 1.1.5.
  625.  
  626. -----------------------------------------------------------------------------
  627. Subject: 109) Has anyone made shared libraries on an IBM RS/6000?
  628.  
  629. Answer: From Sakari Jalovaara: There is a problem: Xm redefines VendorShell
  630. and the AIX linker put _both_ Xm's and Xt's VendorShell into programs.  When
  631. an AIX shared library is created as many references inside the library are
  632. resolved as possible.  If the symbol vendorShellClassRec is defined in libXt
  633. and referenced, say, from a function XtFoo() also in libXt, the "ld" run that
  634. creates the shared library resolves the reference:
  635.  
  636.         XtFoo() -> vendorShellClassRec
  637.  
  638. Then I create the Motif library that has its own vendorShellClassRec and an
  639. XmBar() function that uses it; libXm will also contain a resolved reference to
  640. vendorShellClassRec:
  641.  
  642.         XmBar() -> vendorShellClassRec
  643.  
  644. Finally, I link a program that uses both XtFoo() and XmBar() and the program
  645. will end up with _two_ independent "vendorShellClassRec"s:
  646.  
  647.         XtFoo() -> vendorShellClassRec [Xt version]
  648.         XmBar() -> vendorShellClassRec [Xm version]
  649.  
  650. Instant schizo zaphod mode.  In reality, vendorShellClassRec is not referenced
  651. from functions but from other widget class records.
  652.  
  653. I can't just pull Vendor.o out from the shared Xt (Vendor.o appears to define
  654. the only external symbols redefined by libXm) because AIX shared libraries
  655. apparently can't contain unresolved external references.  If I take out
  656. Vendor.o I have to take out every other file that uses symbols defined there -
  657. and then files that need those files, etc.  I tried it and ended up with three
  658. or four object files in libXt and the res non-sharable.
  659.  
  660. I kludged around this by putting all of libXt (minus Vendor.o) into the shared
  661. libXm.  It isn't a pretty solution but it works - and beats having a
  662. statically linked two-megabyte "periodic" demo...
  663.  
  664.  
  665. -----------------------------------------------------------------------------
  666. Subject: 110)  What is the error  "Unaligned access in XmString" under Ultrix?
  667.  
  668. Answer: Compile  XmString.c with STRINGS_ALIGNED.
  669.  
  670. -----------------------------------------------------------------------------
  671. Subject: 111) TOPIC: KEYSYMS
  672.  
  673. -----------------------------------------------------------------------------
  674. Subject: 112)  What is causing the messages "unknown keysym osfDown..."?  It
  675. happens when I run an application under Motif 1.1
  676.  
  677. Answer: There is an OSF supplied addition to the /usr/lib/X11/XKeysymDB file.
  678. It is found on the release tape and should have been automatically installed
  679. if the installation procedure was followed in the Release Notes.
  680.  
  681. You have to copy (or append) lib/Xm/XKeysymDB into /usr/lib/X11.  This may
  682. require root permission.  It is not clear how to fix the problem if you can't
  683. do this.  The error comes from Xt translation table parsing and can't be fixed
  684. in Motif, so if you can't get root permission you may be stuck.  The file is
  685. not copyrighted so you can install it on other systems.
  686.  
  687. If X has been built so that XKeysymDB is not in this directory, and you don't
  688. know where it is looking, run 'strings libX11.a | grep XKeysymDB' to find the
  689. path.
  690.  
  691. On a Sun running openwin with shared libraries, you may need to put the path
  692. for the library containing XKeysymDB *first* in the path list in
  693. LD_LIBRARY_PATH, or it may find the wrong XKeysymDB in the wrong directory.
  694.  
  695. XKeysymDB simply contains the registered keysym values for the OSF keysyms.
  696. The OSF values are server-independent.  And, all registered keysyms will be
  697. included in an XKeysymDB file to be shipped with X11R5.
  698.  
  699. In the meantime (till all systems are X11R5+), a list of the registered
  700. keysyms can be found in the X11R4 release in mit/doc/Registry/Xregistry.
  701.  
  702.  
  703.  
  704. -----------------------------------------------------------------------------
  705. Subject: 113) What happens if I can't install Motif Keysyms?
  706.  
  707. From: tessi!george@nosun.West.Sun.COM (George Mitchell)
  708.  
  709. Here's what appears to happen if you don't have XKeysymDB in place to define
  710. OSF's virtual keysyms:
  711.  
  712. 1. At class initialize time, for a widget (such as XmText) that uses virtual
  713. keysyms in its event translation table, all entries which refer to those
  714. keysyms fail to parse correctly.  In the case of XmText, instead of ending up
  715. with a translation table with roughly 90 entries, you end up with one that has
  716. 29.
  717.  
  718. 2. XKeysymDB doesn't exist, so you'd assume that KeyPress events will get
  719. translated to plain vanilla keysyms, right?  WRONG!  All Motif widgets install
  720. a virtual keysym translator ANYWAY!  Consequently, the backspace key (for
  721. example) gets translated to the keysym osfBackSpace.
  722.  
  723. 3. Therefore, if you augment or override your widget's translations with
  724. translations that refer to plain vanilla BackSpace, they will never be
  725. triggered, because you will NEVER see plain vanilla BackSpace, only
  726. osfBackSpace.
  727.  
  728. 4. But you can't use osfBackSpace in an event translation entry, because you
  729. don't have XKeysymDB installed!
  730.  
  731. Here's how I'm "dealing" with the problem right now: Motif installs its
  732. virtual keysym translator by calling XtSetKeyTranslator every time a
  733. VendorShell (or subclass) widget is created.  So every time I create a shell,
  734. I immediately call XtSetKeyTranslator (display, XtTranslateKey) to restore the
  735. default translator.  No more funny virtual keysyms!  Now I can reinstall non-
  736. osfKeySym translations and have them work the way I expect.
  737.  
  738.  
  739. -----------------------------------------------------------------------------
  740. Subject: 114) Why has OSF introduced Keysyms into Motif 1.1?  They weren't
  741. there in Motif 1.0.
  742.  
  743. Answer: From: ellis@osf.org
  744.  
  745. Virtual Keysyms are meant to provide a consistent keyboard model for Motif
  746. applications running in a heterogeneous environment in which proprietary (i.e.
  747. vendor specific) non-Motif applications may also be running.
  748.  
  749. First of all, for the sake of the rest of the readers, let's explain why this
  750. is an issue:
  751.  
  752. It would be lovely if Motif's translation tables could just use the obvious
  753. keysyms predefined by X.  For example, there are keysyms for XK_BackSpace,
  754. XK_Delete, XK_Left, XK_Right, etc.  Shouldn't these be the ones that are used
  755. in our translations?  Unfortunately, the problem is not so simple.  Some
  756. specific examples:
  757.  
  758.    While most vendors bind XK_BackSpace to the key at the top right
  759.    of the standard keyboard (often engraved with a leftwards
  760.    pointing arrow), not all do.  In fact, some vendors (including DEC)
  761.    bind that key to XK_Delete.
  762.  
  763.    While most vendors bind the arrow keys to XK_Up, etc, a number of
  764.    vendors (including Sun, on some servers) bind them to function key
  765.    keysyms.
  766.  
  767. A simplistic solution would require the use of xmodmap to change the offending
  768. bindings.  That would work swell in an all Motif environment.  However, OSF's
  769. goal (not always perfectly achieved) is interoperability.  That is, we'd like
  770. to make sure that both Motif and non-Motif programs can happily run in the
  771. same environment.
  772.  
  773. It is expected that a vendor may have a wide variety of existing X-based
  774. software that uses the keysyms as established by that vendor for specific
  775. purposes.  It is expected that these applications may run at the same time as
  776. Motif-based software.  Using xmodmap to change keysyms on the server side
  777. could "break" the existing applications (or at the very least their
  778. documentation) by making some keys unavailable, or by moving the location.
  779.  
  780. So, we chose not to use xmodmap.  By the way, though OpenLook uses a different
  781. implementation (they recompile their virtual translation tables into actual
  782. translation tables), they basically adopted the same approach, presumably for
  783. similar reasons.
  784.  
  785. To work properly, the virtual keysym model we implemented depends on Xlib
  786. finding XKeysymDB installed appropriately (which standard Motif installation
  787. does).  This simply defines the keysyms (not the key they are bound to).  This
  788. unfortunate piece of stupidity is necessary because MIT only includes standard
  789. keysyms in keysymdef.h.  It should be said that our lives would be made easier
  790. if MIT would also see fit to include registered keysyms in keysymdef.h as
  791. well.
  792.  
  793. Motif applications determine how to bind virtual to actual keys by looking for
  794. either a resource or a property on the root window which describes what to do.
  795. Note that this information is on the server side, so that all applications use
  796. the same virtual bindings regardless of where they are running.  Mwm will
  797. happily create the property if it finds a .motifbind file in your home
  798. directory when it starts up.  (Actually, things generally work even if none of
  799. this is done, since if all else fails, the Motif toolkit chooses a virtual
  800. bindings table to use based on the identification of the server).
  801.  
  802. The actual implementation of virtual keys is made possible by a hook in the
  803. Intrinsics.  Undoubtably, the implementation would be simpler and cleaner if
  804. virtual key support was more directly supported by the Intrinsics.  We will be
  805. exploring this possibility in the future.
  806.  
  807.   -- Ellis
  808.  
  809. -----------------------------------------------------------------------------
  810. Subject: 115) TOPIC: ICONS
  811.  
  812. Iconification/de-iconification is a co-operative process between a client and
  813. a window manager.  The relevant standards are set by ICCCM.  Mwm is ICCCM
  814. compliant.  The toplevel (non-override-redirect) windows of an application may
  815. be in three states: WithdrawnState (neither the window nor icon visible),
  816. NormalState (the window visible) or IconicState (the icon window or pixmap
  817. visible).  This information is contained in the WM_STATE property but ordinary
  818. clients are not supposed to look at that (its values have not yet been
  819. standardised).  Movement between the three states is standardised by ICCCM.
  820.  
  821. -----------------------------------------------------------------------------
  822. Subject: 116) How can I keep track of changes to iconic/normal window state?
  823.  
  824. Answer: You can look at the WM_STATE property, but this breaks ICCCM
  825. guidelines.  ICCCM compliant window managers will map windows in changing them
  826. to normal state and unmap them in changing them to iconic state. Look for
  827. StructureNotify events and check the event type:
  828.  
  829.         XtAddEventHandler (toplevel_widget,
  830.                         StructureNotifyMask,
  831.                         False,
  832.                         StateWatcher,
  833.                         (Opaque) NULL);
  834.         ....
  835.         void StateWatcher (w, unused, event)
  836.         Widget w;
  837.         caddr_t unused;
  838.         XEvent *event;
  839.         {
  840.                 if (event->type == MapNotify)
  841.                         printf ("normal\n");
  842.                 else if (event->type == UnmapNotify)
  843.                         printf ("iconified\n");
  844.                 else    printf ("other event\n");
  845.         }
  846.  
  847.  
  848. If you insist on looking at WM_STATE, here is some code (from Ken Sall) to do
  849. it:
  850.  
  851.         /*
  852.         ------------------------------------------------------------------
  853.         Try a function such as CheckWinMgrState below which returns one of
  854.         IconicState | NormalState | WithdrawnState | NULL :
  855.         ------------------------------------------------------------------
  856.         */
  857.         #define WM_STATE_ELEMENTS 1
  858.  
  859.         unsigned long *CheckWinMgrState (dpy, window)
  860.         Display *dpy;
  861.         Window window;
  862.         {
  863.           unsigned long *property = NULL;
  864.           unsigned long nitems;
  865.           unsigned long leftover;
  866.           Atom xa_WM_STATE, actual_type;
  867.           int actual_format;
  868.           int status;
  869.  
  870.             xa_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
  871.  
  872.             status = XGetWindowProperty (dpy, window,
  873.                           xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
  874.                           False, xa_WM_STATE, &actual_type, &actual_format,
  875.                           &nitems, &leftover, (unsigned char **)&property);
  876.  
  877.             if ( ! ((status == Success) &&
  878.                         (actual_type == xa_WM_STATE) &&
  879.                         (nitems == WM_STATE_ELEMENTS)))
  880.                 {
  881.                 if (property)
  882.                     {
  883.                     XFree ((char *)property);
  884.                     property = NULL;
  885.                     }
  886.                 }
  887.             return (property);
  888.         } /* end CheckWinMgrState */
  889.  
  890.  
  891. -----------------------------------------------------------------------------
  892. Subject: 117) How can I check if my application has come up iconic?  I want to
  893. delay initialisation code and other processing.
  894.  
  895. Answer: Use XtGetValues and check for the XmNinitialState value of the
  896. toplevel shell just before XtMainLoop. -- IconicState is iconic, NormalState
  897. is not iconic.
  898.  
  899.  
  900.  
  901.  
  902. -----------------------------------------------------------------------------
  903. Subject: 118) How can I start my application in iconic state?
  904.  
  905. Answer: From the command line
  906.  
  907.         application -iconic
  908.  
  909. Using the resource mechanism, set the resource XmNinitialState to IconicState
  910. of the toplevel shell widget (the one returned from XtInitialise).
  911.  
  912. -----------------------------------------------------------------------------
  913. Subject: 119) How can an application iconify itself?
  914.  
  915. Answer: In R4 and later, use the call XIconifyWindow.
  916.  
  917. For R3, send an event to the root window with a type of WM_CHANGE_STATE and
  918. data IconicState.
  919.  
  920.         void
  921.         IconifyMe (dpy, win)
  922.         Display *dpy;
  923.         Window win;     /* toplevel window to iconify */
  924.         {
  925.                 Atom xa_WM_CHANGE_STATE;
  926.                 XClientMessageEvent ev;
  927.  
  928.                 xa_WM_CHANGE_STATE = XInternAtom (dpy,
  929.                                         "WM_CHANGE_STATE", False);
  930.  
  931.                 ev.type = ClientMessage;
  932.                 ev.display = dpy;
  933.                 ev.message_type = xa_WM_CHANGE_STATE;
  934.                 ev.format = 32;
  935.                 ev.data.l[0] = IconicState;
  936.                 ev.window = win;
  937.  
  938.                 XSendEvent (dpy,
  939.                         RootWindow (dpy, DefaultScreen(dpy)),
  940.                         True,
  941.                         (SubstructureRedirectMask | SubstructureNotifyMask),
  942.                         &ev);
  943.                 XFlush (dpy);
  944.         }
  945.  
  946.  
  947. -----------------------------------------------------------------------------
  948. Subject: 120) How can an application de-iconify itself?
  949.  
  950. Answer: XMapWindow (XtDisplay (toplevel_widget), XtWindow (toplevel_widget)).
  951.  
  952. -----------------------------------------------------------------------------
  953. END OF PART FOUR
  954. --
  955. +----------------------+---+
  956.   Jan Newmarch, Information Science and Engineering,
  957.   University of Canberra, PO Box 1, Belconnen, Act 2616
  958.   Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
  959.